

//
//  SampuxGetCurrentTime.m
//  Sampux
//
//  Created by rzm on 16/9/13.
//  Copyright © 2016年 rzm. All rights reserved.
//

#import "SampuxGetCurrentTime.h"

@implementation SampuxGetCurrentTime
+ (CGFloat)getCurrentTimeWithtimeIntervalSince1970
{
    NSTimeInterval a = [[NSDate date] timeIntervalSince1970];
//    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];

    NSString *timeString = [NSString stringWithFormat:@"%f", a];

    return a;
}

+ (CGFloat)getCurrentTimeWithDate
{    //    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
    NSDate *currentDate = [NSDate date];//获取当前时间，日期
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"HH:mm:ss"];
    NSString *dateString = [dateFormatter stringFromDate:currentDate];
    NSLog(@"dateString:%@",dateString);

    NSArray *arr = [dateString componentsSeparatedByString:@":"];
    NSInteger hour = [arr.firstObject integerValue];
    NSInteger min = [arr[1] integerValue];
    NSInteger second = [arr.lastObject integerValue];
    
    NSLog(@"second ==******* %ld",second + min * 60 + hour *60 *60);
    return second + min * 60 + hour *60 *60;
}
@end
